unit dmda_Product;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dmModule, FR_DSet, FR_DBSet, DB, ADODB;

type
  Tdtmda_Product = class(TdtmModule)
    res_item: TADODataSet;
    adsMasterHelperCode: TStringField;
    adsMasterHasStop: TBooleanField;
    adsMasterWriter: TStringField;
    adsMasterWriteTime: TDateTimeField;
    adsMasterModifier: TStringField;
    adsMasterModifyTime: TDateTimeField;
    adsMasterRemark: TStringField;
    adsMasterProductID: TStringField;
    adsMasterProductCode: TStringField;
    adsMasterProductName: TStringField;
    adsProductType: TADODataSet;
    adsMasterHasDefault: TBooleanField;
    adsMasterHasSysDefine: TBooleanField;
    adsMasterStopMemo: TStringField;
    adsMasterStopDate: TDateTimeField;
    adsMasterStoper: TStringField;
    adsMasterHasCheck: TBooleanField;
    adsMasterChecker: TStringField;
    adsMasterCheckTime: TDateTimeField;
    adsMasterHasUse: TBooleanField;
    adsMasterDeptID: TStringField;
    adsMasterPlaceCode: TStringField;
    adsMasterOrderID: TStringField;
    adsMasterImgType: TStringField;
    adsMasterProductType: TStringField;
    adsMasterEditHelperCode: TStringField;
    adsMasterEditDeptID: TStringField;
    adsMasterEditPlaceCode: TStringField;
    adsMasterEditOrderID: TStringField;
    adsMasterEditImgType: TStringField;
    adsMasterEditProductType: TStringField;
    adsMasterEditHasUse: TBooleanField;
    adsMasterEditHasStop: TBooleanField;
    adsMasterEditHasDefault: TBooleanField;
    adsMasterEditHasSysDefine: TBooleanField;
    adsMasterEditStoper: TStringField;
    adsMasterEditStopDate: TDateTimeField;
    adsMasterEditStopMemo: TStringField;
    adsMasterEditHasCheck: TBooleanField;
    adsMasterEditChecker: TStringField;
    adsMasterEditCheckTime: TDateTimeField;
    adsMasterEditWriter: TStringField;
    adsMasterEditWriteTime: TDateTimeField;
    adsMasterEditModifier: TStringField;
    adsMasterEditModifyTime: TDateTimeField;
    adsMasterEditRemark: TStringField;
    adsMasterEditres_ProductTypeName: TStringField;
    adsMasterEditProductID: TStringField;
    adsMasterEditProductCode: TStringField;
    adsMasterEditProductName: TStringField;
    adsMasterRuleChildID: TStringField;
    adsMasterProductTypeName: TStringField;
    adsDepartment: TADODataSet;
    adsMasterEditres_DeptName: TStringField;
    adsMasterEditSourcePhoto: TBlobField;
    adsProductTypeID: TStringField;
    adsProductTypeRuleChildID: TStringField;
    adsProductTypeCode: TStringField;
    adsProductTypeName: TStringField;
    adsProductTypeFullName: TStringField;
    adsUserCompany: TADODataSet;
    adsMasterDeptName: TStringField;
    res_Unit: TADODataSet;
    adsMasterEditTopTypeName: TStringField;
    adsMasterEditElastic: TStringField;
    adsMasterEditEditionShape: TStringField;
    adsMasterEditFlowerShape: TStringField;
    adsMasterEditSymmetry: TBooleanField;
    adsMasterEditToothSide: TBooleanField;
    adsMasterEditToothSideType: TStringField;
    adsMasterEditProperty: TStringField;
    res_BaseInfo: TADODataSet;
    adsMasterEditres_ElasticName: TStringField;
    adsMasterEditres_EditionShapeName: TStringField;
    adsMasterEditres_FlowerShapeName: TStringField;
    adsMasterEditres_ToothSideTypeName: TStringField;
    adsMasterEditres_PropertyName: TStringField;
    adsMasterTopTypeName: TStringField;
    adsMasterElastic: TStringField;
    adsMasterElasticName: TStringField;
    adsMasterEditionShape: TStringField;
    adsMasterEditionShapeName: TStringField;
    adsMasterFlowerShape: TStringField;
    adsMasterFlowerShapeName: TStringField;
    adsMasterSymmetry: TBooleanField;
    adsMasterToothSide: TBooleanField;
    adsMasterToothSideType: TStringField;
    adsMasterToothSideTypeName: TStringField;
    adsMasterProperty: TStringField;
    adsMasterPropertyName: TStringField;
    adsMasterEditBitPhoto: TBlobField;
    adsMasterEditStockDefUnitID: TStringField;
    adsMasterEditres_StockDefUnitName: TStringField;
    adsMasterEditSpecs: TStringField;
    adsMasterSpecs: TStringField;
    adsMasterUnitID: TStringField;
    adsMasterUnitName: TStringField;
    adsMasterEditHeight: TStringField;
    adsMasterEditWidth: TStringField;
    adsMasterEditBreadth: TStringField;
    adsMasterEditGram: TStringField;
    adsMasterHeight: TStringField;
    adsMasterWidth: TStringField;
    adsMasterBreadth: TStringField;
    adsMasterGram: TStringField;
    adsMasterEditDescription: TStringField;
    adsMasterDescription: TStringField;
    adsMasterEditComposition: TStringField;
    adsMasterEditNeedleInfo: TStringField;
    adsMasterEditOutputNumber: TFloatField;
    adsMasterEditYarnBrand: TStringField;
    adsMasterEditSpandexBrand: TStringField;
    adsMasterEditStripPriceInfo: TStringField;
    adsMasterComposition: TStringField;
    adsMasterNeedleInfo: TStringField;
    adsMasterOutputNumber: TFloatField;
    adsMasterYarnBrand: TStringField;
    adsMasterSpandexBrand: TStringField;
    adsMasterStripPriceInfo: TStringField;
    adsMasterEditYarnSpecs: TStringField;
    adsMasterYarnSpecs: TStringField;
    procedure adsMasterEditProductNameChange(Sender: TField);
    procedure adsMasterEditNewRecord(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
    FOnChangeFlag: integer;
    FProductType: string;
    procedure ModuleInit;override;
    procedure OpenEditDataSet; override;
  end;

var
  dtmda_Product: Tdtmda_Product;

implementation

uses dmConnect,uShare,uGlobal, uSQL, uMsgBox;

{$R *.dfm}

{ Tdtmda_Product }

procedure Tdtmda_Product.ModuleInit;
begin
  FUniqueTable := 'da_Product';
  inherited;
  FOnChangeFlag := 0;
end;

procedure Tdtmda_Product.OpenEditDataSet;
begin
  FMasterEditTable := 'da_Product';
  FMasterKeyField := 'ProductID';
  inherited;

end;

procedure Tdtmda_Product.adsMasterEditProductNameChange(Sender: TField);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) and (FOnChangeFlag=0) then
  try
    FOnChangeFlag := 1;
    adsMasterEdit.FieldByName('HelperCode').ReadOnly := False;
    adsMasterEdit.FieldByName('HelperCode').AsString :=
      GetHzPy(adsMasterEdit.FieldByName('ProductName').AsString);
  finally
    FOnChangeFlag := 0;
  end;
end;

procedure Tdtmda_Product.adsMasterEditNewRecord(DataSet: TDataSet);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) and (FProductType<>'') and (FOnChangeFlag=0) then
  try
    FOnChangeFlag := 1;
    adsMasterEdit.FieldByName('ProductType').ReadOnly := False;
    adsMasterEdit.FieldByName('ProductType').AsString := FProductType;
  finally
    FOnChangeFlag := 0;
  end;
end;

end.
